import verifyIDCard from "./verifyIDCard"
import verifyPhone from "./verifyPhone"

interface ValidatorRuleObject{
  message?:string
}

const transform = (verify) => {
  return ({message}:ValidatorRuleObject) => {
    return {
      validator: (rule, value) => {
        return verify(value) ? Promise.resolve() : Promise.reject(message)
      }
    }
  }
}

const useRules = () => {
  return {
    verifyPhone: transform(verifyPhone),
    verifyIDCard: transform(verifyIDCard),
  }
}
export default useRules